package wzc.design_pattern.creation.prototype.deep_copy;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 王振川
 * @Date 2025/7/19
 */

public class PersonCloneable implements Cloneable {
    public String name;
    public List<String> hobbies;

    public PersonCloneable(String name, List<String> hobbies) {
        this.name = name;
        this.hobbies = hobbies;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        PersonCloneable person = (PersonCloneable) super.clone();
        person.hobbies = new ArrayList<String>(this.hobbies);
        return person;
    }
}
